<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Core\Controller;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;

class UndueController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Register Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles the registration of new users as well as their
    | validation and creation. By default this controller uses a trait to
    | provide this functionality without requiring any additional code.
    |
    */
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function index()
    {
        $user = Auth::user();
        return view('home.undue',compact('user'));
    }
    public function store(Request $request){
        $user = Auth::user();
        if ($request->method() == 'POST') {
            $user->age = $request->get('age');
            $user->nickname = $request->get('nickname');
            $user->email = $request->get('email');
            $user->sex = $request->get('sex');
            $user->education = $request->get('education');
            $user->operation = $request->get('operation');
            $user->nickname = $request->get('nickname');
            $user->estate = $request->get('estate');
            $user->type = $request->get('type');
            $user->industry = $request->get('industry');
            $user->vocation = $request->get('vocation');
            $user->salary = (double)$request->get('salary');
            $user->step = 2;
            if ($user->save()) {
                return redirect('');
            }
        }
        return view('home.undue',compact('user'));
    }


}
